package com.aspose.cells.a.d;

import java.util.ArrayList;

public class zbz {
   private int b;
   private zcp c;
   private zci d;
   private zcc e;
   private ArrayList f = new ArrayList();
   private com.aspose.cells.b.a.b.zq g = new com.aspose.cells.b.a.b.zq();

   public zbz(byte[] var1) throws Exception {
      this.b(var1);
   }

   public boolean a() {
      return this.b == 2;
   }

   public boolean b() {
      return this.b == 3;
   }

   public boolean c() {
      return this.b() || this.f();
   }

   public boolean d() {
      return this.b == 5;
   }

   public boolean e() {
      return this.b == 4;
   }

   public boolean f() {
      return this.d() || this.e();
   }

   public float g() {
      switch(this.b) {
      case 1:
      case 2:
         return this.o();
      case 3:
      case 4:
      case 5:
      default:
         return this.e.c();
      }
   }

   public float h() {
      switch(this.b) {
      case 1:
      case 2:
         return this.o();
      case 3:
      case 4:
      case 5:
      default:
         return this.e.d();
      }
   }

   public com.aspose.cells.b.a.b.zt i() throws Exception {
      return this.n().e();
   }

   public com.aspose.cells.b.a.b.zo j() throws Exception {
      return this.n().d();
   }

   private com.aspose.cells.b.a.b.zq n() throws Exception {
      switch(this.b) {
      case 1:
         return this.p();
      case 2:
         if (this.d.a()) {
            return new com.aspose.cells.b.a.b.zq((float)this.d.b().c(), (float)this.d.b().d(), (float)this.d.b().e(), (float)this.d.b().f());
         }

         return zaq.a();
      case 3:
      case 4:
      case 5:
         return this.e.b();
      default:
         throw new Exception("Unknown metafile image type");
      }
   }

   public int k() {
      return this.f.size();
   }

   public int l() {
      return this.c() ? 0 : this.c.a();
   }

   private static int a(byte[] var0) throws Exception {
      assert var0 != null;

      if (zbn.j(var0)) {
         return 1;
      } else {
         return zbn.k(var0) ? 2 : zbn.n(var0);
      }
   }

   private void b(byte[] var1) throws Exception {
      this.b = a(var1);
      if (this.b == 0) {
         throw new IllegalArgumentException("The specified stream does not contain a valid metafile.\\r\\nParameter name: \"stream");
      } else {
         com.aspose.cells.b.a.d.zh var2 = new com.aspose.cells.b.a.d.zh(var1);

         try {
            com.aspose.cells.b.a.d.za var3 = new com.aspose.cells.b.a.d.za(var2);
            this.a(var3);
            this.b(var3);
         } finally {
            if (var2 != null) {
               var2.a();
            }

         }

      }
   }

   private void a(com.aspose.cells.b.a.d.za var1) throws Exception {
      if (this.c()) {
         this.e = new zcc();
         this.e.a(var1);
      } else {
         if (this.a()) {
            this.d = new zci();
            this.d.a(var1);
         }

         this.c = new zcp();
         this.c.a(var1);
      }

   }

   private void b(com.aspose.cells.b.a.d.za var1) throws Exception {
      int var2 = 0;

      while(true) {
         if (var1.k().i() < var1.k().h()) {
            zcj var3 = new zcj();
            ++var2;
            switch(this.b) {
            case 1:
            case 2:
               var3.a(var1);
               break;
            case 3:
            case 5:
               var3.b(var1);
               if (var3.b()) {
                  continue;
               }
               break;
            case 4:
               var3.b(var1);
               break;
            default:
               throw new Exception("Unknown Metafile type is detected");
            }

            if (!var3.a() && var3.d() != 14) {
               com.aspose.cells.b.a.a.ze.a(this.f, (Object)var3);
               continue;
            }
         }

         return;
      }
   }

   public zcj a(int var1) {
      return (zcj)this.f.get(var1);
   }

   private float o() {
      return this.a() ? (float)this.d.c() : 96.0F;
   }

   private com.aspose.cells.b.a.b.zq p() throws Exception {
      if (this.g.n()) {
         zcb var1 = new zcb(this);
         zco var2 = new zco(var1);
         zcl var3 = new zcl(var1, var2);
         var3.a();
         this.g = var2.e().a();
      }

      return this.g;
   }

   public int m() {
      return this.b;
   }
}
